<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%collection_template}}".
 *
 * @property int $id
 * @property string $template_id
 * @property string $template_name
 * @property int $get_at
 * @property int $updated_at
 * @property string $extra
 *
 * @property CollectionTask[] $collectionTasks
 */
class CollectionTemplate extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%collection_template}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['template_id', 'template_name', 'get_at', 'updated_at'], 'required'],
            [['get_at', 'updated_at'], 'integer'],
            [['extra'], 'string'],
            [['template_id'], 'string', 'max' => 50],
            [['template_name'], 'string', 'max' => 150],
            [['template_id'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'template_id' => Yii::t('app', 'Template ID'),
            'template_name' => Yii::t('app', 'Template Name'),
            'get_at' => Yii::t('app', 'Get At'),
            'updated_at' => Yii::t('app', 'Updated At'),
            'extra' => Yii::t('app', 'Extra'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCollectionTasks()
    {
        return $this->hasMany(CollectionTask::className(), ['template_id' => 'id']);
    }
}
